package com.example.utils;

/**
 * @author: Cherry
 * @create: 2021-09-15 11:34
 * @description: 标准业务异常，用于返回给前端错误码的异常类
 */

public class TypicalRepException extends RuntimeException{

    /**
     * 业务返回错误码
     */
    private Integer code;

    /**
     * 业务错误消息
     */
    private String message;

    /**
     * 错误的附加数据
     */
    private Object data;

    /**
     * 异常包含 code
     */
    public TypicalRepException(Integer code) {
        this.code = code;
    }

    /**
     * 异常包含 code message
     * @param code
     * @param message
     */
    public TypicalRepException(Integer code, String message) {
        super(message);
        this.code = code;
        this.message = message;
    }

    /**
     * 异常包含 code message data
     * @param code
     * @param message
     * @param data
     */
    public TypicalRepException(Integer code, String message, Object data) {
        super(message);
        this.code = code;
        this.message = message;
        this.data = data;
    }

    public Integer getCode() {
        return code;
    }

    @Override
    public String getMessage() {
        return message;
    }

    public Object getData() {
        return data;
    }
}
